// subject.js
var WxParse = require('../../utils/wxParse/wxParse.js');
var app = getApp()
var host = app.globalData.host
var img = app.globalData.image
Page({
  data: {
    yyyy:'kaa0',
    subjectcontent:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that =this;
    var id = options.id
    console.log(id)
    that.setData({
      id: id,
      img: img
    })
    wx.request({
      url: host + '/OperationApi/selOperSubjectContent?id=' + id,
      header: {'content-type': 'application/json'},
      success: function (res) {
        console.log(res)
        
        var x = 0;
        var kaaArr = res.data.data;

        kaaArr.forEach(item => {
          var description = item.description.replace(/\/kaaction/g, img + "/kaaction")
          description = description.replace(/&amp;/g, "&");
          description = description.replace(/&quot;/g, "\"");
          description = description.replace(/&lt;/g, "<");
          description = description.replace(/&gt;/g, ">");
          WxParse.wxParse("kaa"+x, 'html', description, that, 0);
          x = x + 1
        })

        WxParse.wxParseTemArray("kaaArray", 'kaa', kaaArr.length, that)

        that.setData({
          subjectcontent: kaaArr
        })

      }
    })
  },
  // 精选中的商品跳转至购买
  towedproductdetail: function (event) {
    var wedid = event.currentTarget.dataset.wedid
    wx.redirectTo({
      url: '../wedproductdetail/wedproductdetail?id=' + wedid,
    })
  },

})